<template>
  <el-container class="common-layout">
    <el-header>
      <div class="toolbar">
        <span>后台管理</span>
        <Header></Header>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <Menu></Menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script setup>
import { onMounted, toRef } from "vue";
import { Header, Menu } from "./layout/index.js";
import { useRoute, useRouter } from "vue-router";
const route = toRef(useRoute());
const router = useRouter();
onMounted(() => {
  if (!(route.value.meta?.auth && localStorage.getItem("gall_admin_token"))) {
    router.push("/login");
  }
});
</script>
<style lang="scss" scoped>
::v-deep .el-menu {
  height: 100%;
}
.el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  right: 20px;
}
.common-layout {
  height: 100vh;
}
</style>
